﻿using Simple.Common.Helpers;
using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace Simple.Services;

/// <summary>
/// 组织
/// </summary>
public class QHSEOrganizationModel : ModelBase
{
    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime? CreateTime { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }
    /// <summary>
    /// 状态
    /// </summary>
    public int RowState { get; set; } = 0;

    /// <summary>
    /// 组织机构风险等级
    /// </summary>
    public RiskLevelType RiskLevel { get; set; } = RiskLevelType.NoneRisk;

    /// <summary>
    /// 排序值
    /// </summary>
    public int DataSort { get; set; } = 99;

    /// <summary>
    /// id全路径
    /// </summary>
    [MaxLength(1024)]
    public string? IdPath { get; set; } = "";

    /// <summary>
    /// 名称全路径
    /// </summary>
    [MaxLength(1024)]
    public string? NamePath { get; set; } = "";

    /// <summary>
    /// 组织机构级别
    /// </summary>
    [MaxLength(32)]
    public string? OrganizationLevel { get; set; }

    /// <summary>
    /// 组织机构编码
    /// </summary>
    [MaxLength(32)]
    public string? OrganizationCode { get; set; } = "";

    /// <summary>
    /// 组织机构ID
    /// </summary>
    [MaxLength(34)]
    public string OrganizationId { get; set; } = "";

    /// <summary>
    /// 父级ID
    /// </summary>
    [MaxLength(34)]
    public string ParentId { get; set; } = "";

    /// <summary>
    /// 组织机构名称(全名)
    /// </summary>
    [MaxLength(64)]
    public string OrganizationName { get; set; } = "";

    /// <summary>
    /// 组织机构名称缩写
    /// </summary>
    [MaxLength(64)]
    public string? OrganizationAbbreviation { get; set; } = "";

    public override void ConfigureMapper(Profile profile)
    {
        profile.CreateMap<QHSESysOrganization, QHSEOrganizationModel>()
            .ForMember(d => d.OrganizationId, options => options.MapFrom(s => s.OrganizationId))
            .ForMember(d => d.OrganizationName, options => options.MapFrom(s => s.OrganizationName));

        profile.CreateMap<QHSEOrganizationModel, QHSESysOrganization>()
            .ForMember(d => d.OrganizationId, options => options.MapFrom(s => s.OrganizationId))
            .ForMember(d => d.OrganizationName, options => options.MapFrom(s => s.OrganizationName));
    }
}

